<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Set upgrade mode API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'ml-set-upgrade-mode.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-set-upgrade-mode.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-set-upgrade-mode.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/ml-set-upgrade-mode.html" rel="nofollow" target="_blank">../en/ml-set-upgrade-mode.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="ml-apis.html">Machine learning anomaly detection APIs</a></span>
»
<span class="breadcrumb-node">Set upgrade mode API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="ml-revert-snapshot.html">« Revert model snapshots API</a>
</span>
<span class="next">
<a href="ml-start-datafeed.html">Start datafeeds API »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="ml-set-upgrade-mode"></a>Set upgrade mode API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/set-upgrade-mode.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Sets a cluster wide upgrade_mode setting that prepares machine learning indices for an
upgrade.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-set-upgrade-mode-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/set-upgrade-mode.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">POST _ml/set_upgrade_mode</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-set-upgrade-mode-prereqs"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/set-upgrade-mode.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
If the Elasticsearch security features are enabled, you must have <code class="literal">manage_ml</code> or
<code class="literal">manage</code> cluster privileges to use this API. See
<a class="xref" href="security-privileges.html" title="Security privileges">Security privileges</a>.
</li>
</ul>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-set-upgrade-mode-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/set-upgrade-mode.asciidoc">edit</a>
</h3>
</div></div></div>
<p>When upgrading your cluster, in some circumstances you must restart your nodes and
reindex your machine learning indices. In those circumstances, there must be no machine learning jobs running.
You can close the machine learning jobs, do the upgrade, then open all the jobs again.
Alternatively, you can use this API to temporarily halt tasks associated
with the jobs and datafeeds and prevent new jobs from opening. You can also use this
API during upgrades that do not require you to reindex your machine learning indices,
though stopping jobs is not a requirement in that case.</p>
<p>For more information, see <a href="https://www.elastic.co/guide/en/elastic-stack/7.7/upgrading-elastic-stack.html" class="ulink" target="_top">Upgrading the Elastic Stack</a>.</p>
<p>When <code class="literal">enabled=true</code> this API temporarily halts all job and datafeed tasks and
prohibits new job and datafeed tasks from starting.</p>
<p>Subsequently, you can call the API with the enabled parameter set to false,
which causes machine learning jobs and datafeeds to return to their desired states.</p>
<p>You can see the current value for the <code class="literal">upgrade_mode</code> setting by using the
<a class="xref" href="get-ml-info.html" title="Get machine learning info API">get machine learning info API</a>.</p>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>No new machine learning jobs can be opened while the <code class="literal">upgrade_mode</code> setting is
<code class="literal">true</code>.</p>
</div>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-set-upgrade-mode-query-parms"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/set-upgrade-mode.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">enabled</code>
</span>
</dt>
<dd>
(Optional, boolean) When <code class="literal">true</code>, this enables <code class="literal">upgrade_mode</code>. Defaults to
<code class="literal">false</code>.
</dd>
<dt>
<span class="term">
<code class="literal">timeout</code>
</span>
</dt>
<dd>
(Optional, time) The time to wait for the request to be completed. The default
value is 30 seconds.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-set-upgrade-mode-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/set-upgrade-mode.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST _ml/set_upgrade_mode?enabled=true&amp;timeout=10m</pre>
</div>
<div class="console_widget" data-snippet="snippets/1836.console"></div>
<p>When the call is successful, an acknowledged response is returned. For example:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "acknowledged": true
}</pre>
</div>
<p>The acknowledged response will only be returned once all machine learning jobs and datafeeds have
finished writing to the machine learning internal indices. This means it is safe to reindex those
internal indices without causing failures. You must wait for the acknowledged
response before reindexing to ensure that all writes are completed.</p>
<p>When the upgrade is complete, you must set <code class="literal">upgrade_mode</code> to <code class="literal">false</code> for
machine learning jobs to start running again. For example:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST _ml/set_upgrade_mode?enabled=false&amp;timeout=10m</pre>
</div>
<div class="console_widget" data-snippet="snippets/1837.console"></div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="ml-revert-snapshot.html">« Revert model snapshots API</a>
</span>
<span class="next">
<a href="ml-start-datafeed.html">Start datafeeds API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>